package logic

import (
	"context"

	"wxapi/internal/services"
	"wxapi/internal/svc"
	"wxapi/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type GetDoctorOrderEvaluateCountLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewGetDoctorOrderEvaluateCountLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDoctorOrderEvaluateCountLogic {
	return &GetDoctorOrderEvaluateCountLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *GetDoctorOrderEvaluateCountLogic) GetDoctorOrderEvaluateCount(req *types.GetDoctorOrderEvaluateCountReq) (resp *types.GetDoctorOrderEvaluateCountResp, err error) {
	goodCount, err := services.GetEvaluateCountByPoint(l.ctx, l.svcCtx, req.DoctorID, 80, false)
	if err != nil {
		return nil, err
	}

	badCount, err := services.GetEvaluateCountByPoint(l.ctx, l.svcCtx, req.DoctorID, 40, true)
	if err != nil {
		return nil, err

	}

	resp = &types.GetDoctorOrderEvaluateCountResp{
		GoodCount: goodCount,
		BadCount:  badCount,
	}

	return
}
